import time

from src.api.sendMessageApi import sendMessage

infoList = [{
    "current": 1,
    "voltage": 2,
}, {
    "current": 2,
    "voltage": 2,
}]


def send():
    # info = {
    #     "current": 1,
    #     "voltage": 2,
    #     "power": 2,
    #     "electricWork": 2
    # }
    electricWork = 0
    while True:
        for info in infoList:
            info["power"] = info["current"] * info["voltage"]
            electricWork = info["power"] + electricWork
            info["electricWork"] = electricWork
            print("电流：{} 电压：{} 电功率：{} 电功：{}".format(info["current"], info["voltage"], info["power"],
                                                    info["electricWork"]))
            print(info)
            sendMessage(info)
            time.sleep(3)


if __name__ == '__main__':
    send()
